import threading
import time
import tkinter as tk
import pyautogui
import pyautogui as pg
from wheel.cli import pack_f


class MouseTools:
    flag = False
    def __init__(self, window):
        self.window = window
        self.mouse_position = tk.StringVar()

    def getPosition(self):
        while MouseTools.flag:
            x, y = pg.position()
            self.mouse_position.set(f"{x}, {y}")
            time.sleep(0.2)

    def startThreadPosition(self):
        MouseTools.flag = True
        threading.Thread(target=self.getPosition).start()

    def init(self):
        tk.Label(text='鼠标坐标', font=('', 16)).place(x=30, y=10)
        # 坐标输入框
        tk.Entry(textvariable=self.mouse_position).place(x=150, y=15)
        MouseTools.flag = False
        tk.Button(text='获取坐标', command=self.startThreadPosition).place(x=300, y=10)









